package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.User;
import com.atguigu.jxc.service.DamageListGoodsService;
import com.atguigu.jxc.service.OverflowListGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * ClassName: OverFlowListGoodsController
 * Package: com.atguigu.jxc.controller
 * Description:
 *
 * @Author 梅超凡
 * @Create 2025/2/22 16:18
 * @Version 1.0
 */
@RestController
@RequestMapping("/overflowListGoods")
public class OverFlowListGoodsController {


    @Autowired
    private OverflowListGoodsService overflowListGoodsService;

    /**
     * 保存报溢单
     * @param overflowNumber 报溢单号
     * @param overflowDate 报溢日期
     * @param overflowListGoodsStr 报溢商品信息
     * @param remarks 备注
     * @param session session
     * @return ServiceVO
     */
    @RequestMapping("/save")
    public ServiceVO<Object> saveOverFlowListGoods(
            String overflowNumber,
            String overflowDate,
            String overflowListGoodsStr,
            String remarks,
            HttpSession session) {
        User user = (User) session.getAttribute("currentUser");
        return overflowListGoodsService.saveOverFlowListGoods(overflowNumber, overflowDate, overflowListGoodsStr, remarks, user);
    }

    /**
     * 查询报溢单
     * @param sTime 开始时间
     * @param eTime 结束时间
     * @return Map<String,Object>
     */
    @PostMapping("/list")
    public Map<String, Object> listOverFlowListGoods(String sTime, String eTime) {
        return overflowListGoodsService.listOverFlowList(sTime, eTime);
    }
    /**
     * 查询报溢单商品
     * @param overflowListId 报溢单id
     * @return Map<String,Object>
     */
    @PostMapping("/goodsList")
    public Map<String, Object> goodsList(Integer overflowListId) {
        return overflowListGoodsService.goodsList(overflowListId);
    }
}
